
__all__ = ['Doctype']

class Doctype(object):
    def __init__(self, inType="HTML", inDTD="Strict"):
        self.__type = ''
        self.__dtd = ''
        
        self.setType(inType)
        self.setDtd(inDTD)
        
    def setType(self, val):
        if val=='HTML' or val=='XHTML':
            self.__type = val
        else:
            raise PytmlError, "The possible values are only HTML and XHTML, %s was passed instead" %val
        
    def getType(self):
        return self.__type

    def setDtd(self, val):
        if val=='Strict' or val=='Transitional' or val=='Frameset':
            self.__dtd = val
        else:
            raise PytmlError, "The possible values are only Strict, Transitional and Frameset, %s was passed instead" %val
    
    def getDtd(self):
        return self.__dtd
    
    def toString(self):
        if self.__type == "HTML":
            if self.__dtd == "Strict":
                return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
            elif self.__dtd == "Transitional":
                return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
            elif self.__dtd == "Frameset":
                return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
        elif self.__type == "XHTML":
            if self.__dtd == "Strict":
                return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
            elif self.__dtd == "Transitional":
                return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
            elif self.__dtd == "Frameset":
                return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
        